<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //利用闭包来解决变量命名冲突
        var init = (function() {
            var name = "wswj";

            function callname() {
                console.log(name);
            }
            return function() {
                callname();
            }
        }());
        var init1 = (function() {
            var name = "wswj1";

            function callname() {
                console.log(name);
            }
            return function() {
                callname();
            }
        }());
    </script>
</body>

</html>